<?php

/**
 * @package Joomla
 * @subpackage Jmonoslideshow
 * @copyright (C) 2010 - Matthieu BARBE - www.ccomca.com
 * @license GNU/GPL v2
 * 
 * Jmonoslideshow is a Joomla extension for Monoslideshow.
 *
 * Jmonoslideshow uses :
 * Monoslideshow (http://www.monoslideshow.com/)
 * Plupload (http://www.plupload.com/) by Moxicode Systems
 * json class by Michal Migurski, Matt Knapp, Brett Stimmerman
 * jquery a JavaScript Library (http://jquery.com/)
 * getid3 library (http://getid3.sourceforge.net/)
 * swfobject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file (http://code.google.com/p/swfobject/)
 * Chained Selects jQuery Plugin (http://www.appelsiini.net/2010/jquery-chained-selects)
 *
 * Jmonoslideshow is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

class SlideshowHelper

{
	/**
	 * Return paramaters for Configuration
	 * @param array params
	 * @return string
	 */

	function getConfiguration ($params)

	{

		if ($params->get('backgroundTransparency', 0) == 1) $background = 'backgroundColor = "transparent"'; else $background = 'backgroundColor = "'.$params->get('backgroundColor', "#000000").'"';
		if ($params->get('enable_link', 1) == 1) $followImageLinks =  "true"; else $followImageLinks = "false";
		if ($params->get('startWithNavigationWindow', 0) == 1) $startWithNavigationWindow =  "true"; else $startWithNavigationWindow = "false";

		return  '<configuration '.$background.' followImageLinks="'.$followImageLinks.'" startWithNavigationWindow="'.$startWithNavigationWindow.'" scaleMode="'.$params->get('item_scale_mode', "scaleToFill").'" viewportRoundness="'.$params->get('viewportRoundness', "0").'" viewport="'.$params->get('viewport_left', "0").','.$params->get('viewport_top', "0").','.$params->get('viewport_right', "0").','.$params->get('viewport_bottom', "0").',offset" delay="'.$params->get('delay_in_between', "3").'" renderQuality="'.$params->get('renderQuality', "high").'" onAlbumEnd = "'.$params->get('onAlbumEnd', "loop").'" position="'.$params->get('positionItem', "center").'" >';

	}

	/**
	 * Return paramaters for configuration Shadow
	 * @param array params
	 * @return string
	 */

	function getConfigurationShadow ($params)

	{
		return  '<shadow angle="'.$params->get('angleShadowViewport', '45').'" color="'.$params->get('colorShadowViewport', '#000000').'" distance="'.$params->get('distanceShadowViewport', '4').'" sizeX="'.$params->get('BlurSizeXViewport', '12').'" sizeY="'.$params->get('BlurSizeYViewport', '12').'" strength="'.$params->get('strengthBlurViewport', '1').'" alpha="'.$params->get('alphaShadowViewport', '0').'" />';

	}
	
	/**
	 * Return paramaters for Caption
	 * @param array params
	 * @return string
	 */

	function getCaption ($params)

	{
		if ($params->get('showCount', 0) == 1) $showCount =  "true"; else $showCount = "false";
		
		return  '<caption backgroundRoundness="'.$params->get('backgroundRoundness_caption', "10").'" backgroundAlpha="'.$params->get('backgroundtransparency_caption', "0.75").'" backgroundColor="'.$params->get('backgroundColor_caption', "#000000").'" displayMode="'.$params->get('displayMode_caption', "always").'" position="'.$params->get('position_caption', "topLeft").'" backgroundType="'.$params->get('backgroundType_caption', "fitTextLines").'" showCount="'.$showCount.'" countSeparator="'.$params->get('countSeparator', "/").'" width="'.$params->get('widthCaption', "0").'" margin="'.$params->get('marginLeftCaption', 10).','.$params->get('marginTopCaption', 10).','.$params->get('marginRighCaption', 10).','.$params->get('marginBottomCaption', 10).'" padding="'.$params->get('paddingLeftCaption', 5).','.$params->get('paddingTopCaption', 5).','.$params->get('paddingRightCaption', 5).','.$params->get('paddingBottomCaption', 5).'">';

	}

	/**
	 * Return paramaters for Caption Shadow
	 * @param array params
	 * @return string
	 */

	function getCaptionShadow ($params)

	{
		return  '<shadow angle="'.$params->get('angleShadowCaption', '45').'" color="'.$params->get('colorShadowCaption', '#000000').'" distance="'.$params->get('distanceShadowCaption', '0').'" sizeX="'.$params->get('BlurSizeXCaption', '12').'" sizeY="'.$params->get('BlurSizeYCaption', '12').'" strength="'.$params->get('strengthBlurCaption', '1').'" alpha="'.$params->get('alphaShadowCaption', '1').'" />';

	}

	/**
	 * Return paramaters for Caption title
	 * @param array params
	 * @return string
	 */

	function getCaptionTitle ($params)

	{

		return  '<title font="'.$params->get('font_title', "Arial").'" size="'.$params->get('size_title', "22").'" color="'.$params->get('color_title', "#fffef1").'" style="'.$params->get('style_title', "normal").'" weight="'.$params->get('weight_title', "normal").'" letterSpacing="'.$params->get('letter_spacing_title', 0).'"/>';

	}

	

	/**
	 * Return paramaters for Caption description
	 * @param array params
	 * @return string
	 */

	function getCaptionDescription ($params)

	{

		return  '<description font="'.$params->get('font_description', "Arial").'" size="'.$params->get('size_description', "12").'" color="'.$params->get('color_description', "#fffef1").'" style="'.$params->get('style_description', "normal").'" weight="'.$params->get('weight_description', "normal").'" letterSpacing="'.$params->get('letter_spacing_description', 0).'"/>';

	}

	

	/**

	 * Return paramaters for controller

	 * @param array params

	 * @return string

	 */

	function getController ($params)

	{

		if ($params->get('showScrubBar', 1) == 1) $showScrubBar = "true"; else $showScrubBar = "false";
		if ($params->get('autoHideControl', 1) == 1) $autoHideControl = "true"; else $autoHideControl =  "false";
		if ($params->get('autoPlayControl', 1) == 1) $autoPlayControl =  "true"; else $autoPlayControl = "false";
		if ($params->get('startHiddenControl', 0) == 1) $startHiddenControl = "true"; else $startHiddenControl = "false";
		if ($params->get('showNavigationButton', 1) == 1) $showNavigationButton = "true"; else $showNavigationButton = "false";
		if ($params->get('showFullScreenButton', 0) == 1) $showFullScreenButton = "true"; else $showFullScreenButton = "false";
		if ($params->get('showMuteButton', 0) == 1) $showMuteButton = "true"; else $showMuteButton = "false";
		if ($params->get('showNextButton', 1) == 1) $showNextButton = "true"; else $showNextButton = "false";
		if ($params->get('showPlayButton', 1) == 1) $showPlayButton = "true"; else $showPlayButton = "false";
		if ($params->get('showPreviousButton', 1) == 1) $showPreviousButton = "true"; else $showPreviousButton = "false";

		return  '<controller showScrubBar="'.$showScrubBar.'" type="'.$params->get('control_type', "normal").'" backgroundAlpha="'.$params->get('backgroundAlphaControl', "0.75").'" backgroundColor="'.$params->get('backgroundColorControl', "#000000").'" backgroundRoundness="'.$params->get('backgroundRoundnessControl', 30).'" strokeColor="'.$params->get('strokeColorControl', '#fffef1').'" strokeWidth = "'. $params->get('strokeWidthControl', 2).'" strokeType="'.$params->get('strokeTypeControl', 'round').'" margin="'.$params->get('marginLeftControl', 20).','.$params->get('marginTopControl', 20).','.$params->get('marginRighControl', 20).','.$params->get('marginBottomControl', 20).'" padding="'.$params->get('paddingLeftControl', 10).','.$params->get('paddingTopControl', 10).','.$params->get('paddingRightControl', 10).','.$params->get('paddingBottomControl', 10).'" position="'.$params->get('position_controle', 'bottomCenter').'" appearTime="'.$params->get('appearTimeControl', 1).'" disappearMode="'.$params->get('disappearModeControl', 'vertical').'" disappearDelay="'.$params->get('disappearDelayControl', 3).'" autoHide="'.$autoHideControl.'" autoPlay="'.$autoPlayControl.'" startHidden="'.$startHiddenControl.'" iconColorUp="'.$params->get('iconColorUp', '#fffef1').'"  iconColorDisable="'.$params->get('iconColorDisable', '#7f7f78').'" iconColorOver="'.$params->get('iconColorOver', '#f92672').'" iconHeight="'.$params->get('iconHeight', 17).'" iconWidth="'.$params->get('iconWidth', 17).'" iconSpacing="'.$params->get('iconSpacing', '2').'" showNavigationButton="'.$showNavigationButton.'" showFullScreenButton="'.$showFullScreenButton.'" showMuteButton="'.$showMuteButton.'" showNextButton="'.$showNextButton.'" showPlayButton="'.$showPlayButton.'" showPreviousButton="'.$showPreviousButton.'">';

	}

	

	/**
	 * Return paramaters for controller shadow
	 * @param array params
	 * @return string
	 */

	function getControllerShadow ($params)

	{

		return  '<shadow color="'.$params->get('shadowColorControl', '#000000').'" alpha="'.$params->get('alphaShadowControl', 1).'" />';

	}
	
	 /**
	 * Return paramaters for navigation
	 * @param array params
	 * @return string
	 */

	function getNavigation ($params)

	{

		return  '<navigation backgroundColor="'.$params->get('BackgroundColorNavigation', '#000000').'" backgroundAlpha="'.$params->get('backgroundAlphaNavigation', '0.75').'"  backgroundRoundness="'.$params->get('backgroundRoundnessNavigation', '30').'" strokeColor="'.$params->get('strokeColorNavigation', '#fffef1').'" strokeWidth="'.$params->get('strokeWidthNavigation', 2).'" strokeType="'.$params->get('strokeTypeNavigation', 'round').'" position="'.$params->get('positionNavigation', 'center').'" margin="'.$params->get('marginLeftNavigation', 80).','.$params->get('marginTopNavigation', 80).','.$params->get('marginRightNavigation', 80).','.$params->get('marginBottomNavigation', 80).'" padding="'.$params->get('paddingLeftNavigation', 20).','.$params->get('paddingTopNavigation', 20).','.$params->get('paddingRightNavigation', 20).','.$params->get('paddingBottomNavigation', 20).'"  backgroundOverlayColor="'.$params->get('backgroundOverlayColorNavigation', '#000000').'"  backgroundOverlayAlpha="'.$params->get('backgroundOverlayAlphaNavigation', '0.65').'"  backgroundOverlayFadeInTime="'.$params->get('backgroundOverlayFadeInTimeNavigation', '0.3').'" >';

	}
	
	 /**
	 * Return paramaters for navigation albums
	 * @param array params
	 * @return string
	 */

	function getNavigationAlbums ($params)

	{

		return  '<albums  />';

	}
	
	/**
	 * Return paramaters for Thumbnail Navigation
	 * @param array params
	 * @return string
	 */

	function getThumbnailNavigation ($params)

	{
		if ($params->get('showPreviousButtonPermanentNavigation', 1) == 1) $showPreviousButton = "true"; else $showPreviousButton = "false";
		if ($params->get('showNextButtonPermanentNavigation', 1) == 1) $showNextButton = "true"; else $showNextButton = "false";
		return  '<thumbnailNavigation  type="'.$params->get('typePermanentNavigation', 'none').'" backgroundColor="'.$params->get('backgroundColorPermanentNavigation', '#000000').'" backgroundAlpha="'.$params->get('backgroundAlphaPermanentNavigation', '0.75').'" backgroundRoundness="'.$params->get('backgroundRoundnessPermanentNavigation', '10').'" strokeColor="'.$params->get('strokeColorPermanentNavigation', '#fffef1').'" strokeWidth="'.$params->get('strokeWidthPermanentNavigation', '0').'" strokeType="'.$params->get('strokeTypePermanentNavigation', 'round').'" margin="'.$params->get('marginLeftPermanentNavigation', 5).','.$params->get('marginTopPermanentNavigation', 5).','.$params->get('marginRightPermanentNavigation', 5).','.$params->get('marginBottomPermanentNavigation', 5).'" padding="'.$params->get('paddingLeftPermanentNavigation', 5).','.$params->get('paddingTopPermanentNavigation', 5).','.$params->get('paddingRightPermanentNavigation', 5).','.$params->get('paddingBottomPermanentNavigation', 5).'" position="'.$params->get('positionPermanentNavigation', 'bottomCenter').'" iconMode="'.$params->get('iconModePermanentNavigation', 'horizontal').'" iconWidth="'.$params->get('iconWidthPermanentNavigation', '17').'" iconHeight="'.$params->get('iconHeightPermanentNavigation', '17').'" iconMargin="'.$params->get('iconMarginLeftPermanentNavigation', 5).','.$params->get('iconMarginTopPermanentNavigation', 5).','.$params->get('iconMarginRightPermanentNavigation', 5).','.$params->get('iconMarginBottomPermanentNavigation', 5).'" showPreviousButton="'.$showPreviousButton.'" showNextButton="'.$showNextButton.'">';

	}
	
	/**
	 * Return paramaters for Thumbnail Navigation Shadow
	 * @param array params
	 * @return string
	 */

	function getThumbnailNavigationShadow ($params)

	{

		return  '<shadow angle="'.$params->get('angleShadowPermanentNavigation', '45').'" color="'.$params->get('shadowColorPermanentNavigation', '#000000').'" distance="'.$params->get('distanceShadowPermanentNavigation', '4').'" sizeX="'.$params->get('BlurSizeXPermanentNavigation', '12').'" sizeY="'.$params->get('BlurSizeYPermanentNavigation', '12').'" strength="'.$params->get('strengthBlurPermanentNavigation', '1').'" alpha="'.$params->get('alphaShadowPermanentNavigation', '1').'" />';

	}
	
	/**
	 * Return paramaters for Thumbnail Navigation Items
	 * @param array params
	 * @return string
	 */

	function getThumbnailNavigationItems ($params)

	{

		return  '<items rows="'.$params->get('rowsPermanentNavigationItems', '0').'"  columns="'.$params->get('columnsPermanentNavigationItems', '0').'" height="'.$params->get('heightPermanentNavigationItems', '30').'" width="'.$params->get('widthPermanentNavigationItems', '30').'" imageScaleMode = "'.$params->get('imageScaleModeNavigationItems', 'scaleToFill').'" verticalSpacing = "'.$params->get('verticalSpacingNavigationItems', '2').'" horizontalSpacing = "'.$params->get('horizontalSpacingNavigationItems', '2').'" strokeColor="'.$params->get('strokeColorNavigationItems', '#fffef1').'" strokeWidth="'.$params->get('strokeWidthNavigationItems', '0').'" strokeType="'.$params->get('strokeTypeNavigationItems', 'round').'" imageRoundness="'.$params->get('imageRoundnessNavigationItems', '4').'" imageBackgroundColor="'.$params->get('imageBackgroundColorNavigationItems', '#000000').'" imageBackgroundAlpha="'.$params->get('imageBackgroundAlphaNavigationItems', '0').'">';

	}
	
	/**
	 * Return paramaters for Thumbnail Navigation Items Shadow
	 * @param array params
	 * @return string
	 */

	function getThumbnailNavigationItemsShadow ($params)

	{
		
		return  '<shadow angle="'.$params->get('angleShadowNavigationItems', '45').'" color="'.$params->get('colorShadowNavigationItems', '#000000').'" distance="'.$params->get('distanceShadowNavigationItems', '0').'" sizeX="'.$params->get('BlurSizeXNavigationItems', '0').'" sizeY="'.$params->get('BlurSizeYNavigationItems', '0').'" strength="'.$params->get('strengthBlurNavigationItems', '1').'" alpha="'.$params->get('alphaShadowNavigationItems', '0').'" />';

	}
	
	/**
	 * Return paramaters for Thumbnail Navigation Items Transition
	 * @param array params
	 * @return string
	 */

	function getThumbnailNavigationItemsTransition ($params)

	{
		
		return  '<transition distanceX="'.$params->get('distanceXNavigationItemsTransition', '0').'" distanceY="'.$params->get('distanceYNavigationItemsTransition', '0').'" scale="'.$params->get('scaleNavigationItemsTransition', '1.1').'" highlight="'.$params->get('highlightNavigationItemsTransition', 'overlay').'" highlightStrength="'.$params->get('highlightStrengthNavigationItemsTransition', '0.25').'" time="'.$params->get('timeNavigationItemsTransition', '0.1').'" type="'.$params->get('typeNavigationItemsTransition', 'highlight').'">';

	}
	
	/**
	 * Return paramaters for Thumbnail Navigation Items Transition
	 * @param array params
	 * @return string
	 */

	function getThumbnailNavigationItemsTransitionShadow ($params)

	{
		
		return  '<shadow angle="'.$params->get('angleShadowNavigationItemsTransition', '45').'" color="'.$params->get('colorShadowNavigationItemsTransition', '#000000').'" distance="'.$params->get('distanceShadowNavigationItemsTransition', '0').'" sizeX="'.$params->get('BlurSizeXNavigationItemsTransition', '16').'" sizeY="'.$params->get('BlurSizeYNavigationItemsTransition', '16').'" strength="'.$params->get('strengthBlurNavigationItemsTransition', '2').'" alpha="'.$params->get('alphaShadowNavigationItemsTransition', '1').'" />';
	}

	/**
	 * Return paramaters for scrubBar
	 * @param array params
	 * @return string
	 */

	function getScrubBar ($params)

	{

		return '<scrubBar backgroundColor="'.$params->get('backgroundColorScrub', '#7f7f78').'" loadingColor="'.$params->get('loadingColorScrub', '#fffef1').'" progressColor="'.$params->get('progressColorScrub', '#f92672').'" height="'.$params->get('heightScrub', '8').'" width="'.$params->get('widthScrub', '50').'" margin="'.$params->get('marginLeftScrub', '4').','.$params->get('marginTopScrub', '0') .','.$params->get('marginRightScrub', '4').','.$params->get('marginBottomScrub', '0').'"  />';

	}

	 /**
	 * Return paramaters for Progress Control
	 * @param array params
	 * @return string
	 */

	function getProgressControl ($params)

	{
		($params->get('typeProgress', 'pie') == "pie") ? $typeProgress = "" : $typeProgress = "type=\"".$params->get('typeProgress')."\"";
		($params->get('widthProgress', '100') == 100) ? $widthProgress = "" : $widthProgress = "width=\"".$params->get('widthProgress')."\"";
		($params->get('heightProgress', '5') == 5) ? $heightProgress = "" : $heightProgress = "height=\"".$params->get('heightProgress')."\"";
		($params->get('radiusProgress', '12') == 12) ? $radiusProgress = "" : $radiusProgress = "radius=\"".$params->get('radiusProgress')."\"";
		($params->get('positionProgress', 'bottomRight') == 'bottomRight') ? $positionProgress = "" : $positionProgress = "position=\"".$params->get('positionProgress')."\"";
		($params->get('delayProgress', '0.25') == '0.25') ? $delayProgress = "" : $delayProgress = "delay=\"".$params->get('delayProgress')."\"";
		($params->get('easingTimeProgress', '0.5') == '0.5') ? $easingTimeProgress = "" : $easingTimeProgress = "easingTime=\"".$params->get('easingTimeProgress')."\"";
		($params->get('transitionTimeProgress', '0.5') == '0.5') ? $transitionTimeProgress = "" : $transitionTimeProgress = "transitionTime=\"".$params->get('transitionTimeProgress')."\"";
		($params->get('backgroundColorProgress', '#000000') == '#000000') ? $backgroundColorProgress = "" : $backgroundColorProgress = "backgroundColor=\"".$params->get('backgroundColorProgress')."\"";
		($params->get('progressColorProgress', '#fffef1') == '#fffef1') ? $progressColorProgress = "" : $progressColorProgress = "progressColor=\"".$params->get('progressColorProgress')."\"";
		($params->get('backgroundAlphaProgress', '0.75') == '0.75') ? $backgroundAlphaProgress = "" : $progressColorProgress = "backgroundAlpha=\"".$params->get('backgroundAlphaProgress')."\"";
		($params->get('strokeColorProgress', '#fffef1') == '#fffef1') ? $strokeColorProgress = "" : $strokeColorProgress = "strokeColor=\"".$params->get('strokeColorProgress')."\"";
		($params->get('strokeWidthProgress', '2') == '2') ? $strokeWidthProgress = "" : $strokeWidthProgress = "strokeWidth=\"".$params->get('strokeWidthProgress')."\"";
		($params->get('strokeTypeProgress', 'round') == 'round') ? $strokeTypeProgress = "" : $strokeTypeProgress = "strokeType=\"".$params->get('strokeTypeProgress')."\"";
		
		return '<progress '.$typeProgress.' '.$widthProgress.' '.$heightProgress.' '.$positionProgress.' '.$delayProgress.' '.$easingTimeProgress.'  '.$backgroundColorProgress.' '.$progressColorProgress.' '.$backgroundAlphaProgress.' '.$radiusProgress.' margin="'.$params->get('marginLeftProgress', 20).','.$params->get('marginTopProgress', 20).','.$params->get('marginRightProgress', 20).','.$params->get('marginBottomProgress', 20).'" padding="'.$params->get('paddingLeftProgress', 6).','.$params->get('paddingTopProgress', 6).','.$params->get('paddingRightProgress', 6).','.$params->get('paddingBottomProgress', 6).'" '.$transitionTimeProgress.' '.$strokeColorProgress.' '.$strokeWidthProgress.' '.$strokeTypeProgress.' >'.SlideshowHelper::getShadow ($params->get('colorShadowProgress', '#000000'), $params->get('alphaShadowProgress', '1'), $params->get('BlurSizeXProgress', '12'), $params->get('BlurSizeYProgress', '12'), $params->get('strengthBlurProgress', '1'), $params->get('distanceShadowProgress', '0'), $params->get('angleShadowProgress', '45'), $params->get('qualityShadowProgress', '3') ).'</progress>';

	}
	

	/**

	 * Return paramaters for reflexion
	 * @param array params
	 * @return string
	 */

	function getReflexion ($params)

	{

		

		return  '<reflection alpha="'.$params->get('reflection_alpha', "0.5").'" height="'.$params->get('reflection_height', "0").'" offset="'.$params->get('reflection_offset', "0").'" />';

	}

	

	/**
	 * Return paramaters for transition
	 * @param array params
	 * @return string
	 */

	function getTransition ($params)

	{

		return  '<transition size="'.$params->get('sizeTransition', "0.1").'" strength="'.$params->get('strengthTransition', "0.1").'" direction="'.$params->get('transition_direction', "leftToRight").'" easing="'.$params->get('transition_easing', "easeInOut").'" time="'.$params->get('transition_time', "0.5").'" type="'.$params->get('transition_type', "blend").'" kenBurnsMode="'.$params->get('kenBurnsMode', "none").'" kenBurnsTime="'.$params->get('kenBurnsTime', "3").'" kenBurnsStrength="'.$params->get('kenBurnsStrength', "0.15").'" channel1="'.$params->get('channel1', "red").'"  channel2="'.$params->get('channel2', "red").'" pivotPoint="'.$params->get('pivotPoint', "topLeft").'"  />';

	}

	

	/**
	 * Return paramaters for mark
	 * @param array params
	 * @return string
	 */

	function getMark ($params)

	{

		

		return  '<mark source="'.JURI::root().'images/stories/'.$params->get('markSource').'" alpha="'.$params->get('alphaMark', 1).'" margin="'.$params->get('marginLeftMark', '10').','.$params->get('marginTopMark', '10').','.$params->get('marginRightMark', '10').','.$params->get('marginBottomMark', '10').'" position="'.$params->get('positionMark', 'topRight').'" transitionTime="'.$params->get('transitionTimeMark', '0.5').'">'.SlideshowHelper::getShadow ($params->get('colorShadowMark', '#000000'), $params->get('alphaShadowMark', '1'), $params->get('BlurSizeXMark', '12'), $params->get('BlurSizeYMark', '12'), $params->get('strengthBlurMark', '1'), $params->get('distanceShadowMark', '4'), $params->get('angleShadowMark', '45'), $params->get('qualityShadowMark', '3') ).'</mark>';

	}

	

	/**
	 * Return content
	 * @param array params
	 * @param array row
	 * @return string
	 */

	function getContent ($params, $type, $row, $albums)

	{

		$content = '';

		if ($type == 'slideshow')

			{

			foreach ($row as $item)

				{

					

					$content .= SlideshowHelper::getContentType ($params, $item);

					

				}

			}

			else

			{

				$kk = 0;

				for ($ii=0, $nn=count( $albums ); $ii < $nn; $ii++)

					{

					$album = &$albums[$ii];

	

					$content .= "'<album thumbnail=\"".JURI::root()."images/monoslideshow/albums/".$album->id.".jpg\" title = \"".$album->title."\" description = \"".$album->description."\" itemPath=\"".JURI::root()."images/monoslideshow/images\" thumbnailPath=\"".JURI::root()."images/monoslideshow/images/thumbnails\" >' +";

					$content .= "'<contents>' +";

	

					$currentAlbum 	= $album->id;

					$itemStartIdx 	= $album->item_startIdx;

					$itemEndIdx 		= ($album->item_startIdx + $album->numitems_active);

	

					$k = 0; $num = 1;



					// loop over all images of the current album (itemStartIdx < articleIdx <itemEndIdx)

					for ($i = $itemStartIdx; $i < $itemEndIdx; $i++)

						{	

						// check for a valid index

						if (($i < 0) || ($i > sizeof($row)))

							break;

							

							

						$item = & $row[$i];

						$content .= SlideshowHelper::getContentType ($params, $item);

						}

					$content .= "'</contents>' +";

					$content .= "'</album>' +";

					$kk = 1 - $kk;

					}

			}

		

		return  $content;

	}

	

	/**
	 * Return content type
	 * @return string
	 */

	function getContentType ($params, $item)

	{
		$media = '';
		$itemParams = new JParameter($item->params);
		if ($item->extension == "") $extension = "jpg"; else $extension = $item->extension;
		if ($params->get('show_title', 1) == 1) $title= 'title="'.SlideshowHelper::filterQuote($item->title).'"'; else $title = '';
		if ($params->get('show_description', 1) == 1) $description= 'description="'.SlideshowHelper::filterQuote($item->description).'"'; else $description = '';
		if ($params->get('enable_link', 1) == 1) $link ='link="'.$item->link.'" target="'.$params->get('target_link', "_parent").'"'; else $link = '';
		if ($itemParams->get('action_media', 'none')!= "none") $action = 'action="'.$itemParams->get('action_media').'"'; else $action = '';
		if ($itemParams->get('item_scale_mode', 'module')!= "module") $item_scale_mode =  "scaleMode=\"".$itemParams->get('item_scale_mode')."\""; else $item_scale_mode = "";
			if ($itemParams->get('position', 'center')!= "center") $position = "position=\"".$itemParams->get('position')."\""; else $position= "";
			if ($itemParams->get('item_scale_mode', 'module') == "none") $margin = "margin=\"".$itemParams->get('marginLeft', 0).",".$itemParams->get('marginTop', 0).",".$itemParams->get('marginRight', 0).",".$itemParams->get('marginBottom', 0)."\""; else $margin = "";
		if ($item->type != 2)

			{
				if ($itemParams->get('delayImage', 0)!= 0) $delayImage = "delay=\"".$itemParams->get('delayImage', 0)."\""; else $delayImage = "";
				$media .= "'<image source=\"".$item->id.".".$extension."\" ".$title." ".$description."  ".$link." ".$action."  >' +";
				$media .= "'<configuration ".$delayImage." ".$item_scale_mode."  ".$position."  ".$margin." />' +";
				$media .= "'</image>' +";

			}
			else
			{
				$media .= "'<video source=\"".$item->id.".".$item->extension."\" ".$title." ".$description." ".$link." ".$action."  thumbnail=\"".JURI::root()."images/monoslideshow/images/thumbnails/".$item->id.".jpg\" >' +";
				$media .= "'<configuration volume=\"".$itemParams->get('volumeVideo', 1)."\"  ".$item_scale_mode."  ".$position."  ".$margin."  />'+";
				$media .= "'</video>'+";
			}

		return  $media;

	}

	/**
	 * Return paramaters for Shadow
	 * @param string colorShadow
	 * @param int alphaShadow
	 * @param int BlurSizeX
	 * @param int BlurSizeY
	 * @param int strengthShadow
	 * @param int distanceShadow
	 * @param int angleShadow
	 * @param int qualityShadow
	 * @return string
	 */

	function getShadow ($colorShadow, $alphaShadow, $BlurSizeX, $BlurSizeY, $strengthShadow, $distanceShadow, $angleShadow, $qualityShadow = 1)

	{
		($colorShadow == "#000000") ? $colorShadow = "" : $colorShadow = "color=\"".$colorShadow."\"";
		($alphaShadow == "1") ? $alphaShadow = "" : $alphaShadow = "alpha=\"".$alphaShadow."\"";
		($BlurSizeX == "12") ? $BlurSizeX = "" : $BlurSizeX = "sizeX=\"".$BlurSizeX."\"";
		($BlurSizeY == "12") ? $BlurSizeY = "" : $BlurSizeY = "sizeY=\"".$BlurSizeY."\"";
		($strengthShadow == "1") ? $strengthShadow = "" : $strengthShadow = "strength=\"".$strengthShadow."\"";
		($distanceShadow == "0") ? $distanceShadow = "" : $distanceShadow = "distance=\"".$distanceShadow."\"";
		($angleShadow == "45") ? $angleShadow = "" : $angleShadow = "angle=\"".$angleShadow."\"";
		($qualityShadow == "3") ? $qualityShadow = "" : $qualityShadow = "quality=\"".$qualityShadow."\"";
		return '<shadow '.$colorShadow.' '.$alphaShadow.' '.$BlurSizeX.' '.$BlurSizeY.' '.$strengthShadow.' '.$distanceShadow.' '.$angleShadow.' '.$qualityShadow.'  />';

	}
	
	/**
	 * Return flashvars
	 * @param array params
	 * @return string
	 */

	function getFlashvars ($params, $type, $row, $albums)

	{
		//load parameters from your model
		if ($params->get('models', 0) != 0)
			{
				$model = SlideshowHelper::getModelParameters($params->get('models'));
				if ($model) 
				{											   
					foreach ($model as $modelobject)
						{
						$params = new JParameter($modelobject->params);
						}
				}
			}
		if ($params->get('show_registration', 1) == 1) $show_registration = "true"; else $show_registration = "false";
		if ($params->get('showLogo', 1) == 1) $showLogo =  "true"; else $showLogo = "false";
		$mark ='';
		if ($params->get('markSource', "-1") != -1 )
			{
			$mark = "'".SlideshowHelper::getMark($params)."'+";
			}
		return "var flashvars = {showRegistration: '".$show_registration."', showLogo:'".$showLogo."', xml: escape(
		'<album itemPath=\"".JURI::root()."images/monoslideshow/images\" thumbnailPath=\"".JURI::root()."images/monoslideshow/images/thumbnails\" >' +

		'".SlideshowHelper::getConfiguration($params)."' +
		'".SlideshowHelper::getProgressControl($params)."' +
		'".SlideshowHelper::getCaption($params)."' +
		'".SlideshowHelper::getCaptionShadow($params)."' +
		'".SlideshowHelper::getCaptionTitle($params)."' +
		'".SlideshowHelper::getCaptionDescription($params)."' +
		'</caption>' +
		'".SlideshowHelper::getController($params)."' +
		'".SlideshowHelper::getControllerShadow($params)."' +
		'".SlideshowHelper::getScrubBar($params)."' +
		'</controller>' +
		'".SlideshowHelper::getNavigation($params)."' +
		'".SlideshowHelper::getNavigationAlbums($params)."' +
		'</navigation>' +
		'".SlideshowHelper::getThumbnailNavigation($params)."' +
		'".SlideshowHelper::getThumbnailNavigationShadow($params)."' +
		'".SlideshowHelper::getThumbnailNavigationItems($params)."' +
		'".SlideshowHelper::getThumbnailNavigationItemsShadow($params)."' +
		'".SlideshowHelper::getThumbnailNavigationItemsTransition($params)."' +
		'".SlideshowHelper::getThumbnailNavigationItemsTransitionShadow($params)."' +
		'</transition>' +
		'</items>' +
		'</thumbnailNavigation>' +
		'".SlideshowHelper::getReflexion($params)."' +
		'".SlideshowHelper::getTransition($params)."' +
		".$mark."
		'".SlideshowHelper::getConfigurationShadow($params)."' +
		'</configuration>' +
		'<contents>' +
		".SlideshowHelper::getContent($params, $type, $row, $albums)."
		'</contents>' +
		'</album>'
		)};
		";
		
	}	

	/**
	 * Return swfobject
	 * @param array params
	 * @return string
	 */

	function getSwfobject ($params, $type, $row, $albums)
	{
		//load swfobject script
		if ($params->get('use_swfobject', 1)) 
			{
				$doc = &JFactory::getDocument();
				$doc->addScript(JURI::Root() . 'components/com_jmonoslideshow/assets/js/swfobject.js'); 
			}
			
		//load parameters from your model
		$flash_width = $params->get('flash_width', "500");
		$flash_height = $params->get('flash_height', "250");
		if ($params->get('models', 0) != 0)
			{
				$model = SlideshowHelper::getModelParameters($params->get('models'));
				if ($model) 
				{											   
					foreach ($model as $modelobject)
						{
						$ModelParams = new JParameter($modelobject->params);
						}
						if ($ModelParams->get('flash_width', "")) $flash_width = $ModelParams->get('flash_width'); else $flash_width = $params->get('flash_width', "500");
						if ($ModelParams->get('flash_height', "")) $flash_height = $ModelParams->get('flash_height'); else $flash_height = $params->get('flash_height', "250");
				}
			}
		
		$paramatercomponent = &JComponentHelper::getParams( 'com_jmonoslideshow' );
		return  '<script type="text/javascript">
		'.SlideshowHelper::getFlashvars($params, $type, $row, $albums).'
		var params = {allowScriptAccess: "sameDomain", allowfullscreen: "true", allowNetworking: "all", wmode: "transparent"};
		var attributes = {};
		swfobject.embedSWF("'.JURI::root().''.$paramatercomponent->get( 'directory', 'images/stories/monoslideshow/monoslideshow.swf' ) .'", "'.$params->get('div_id', "jmonoslideshow").'", "'.$flash_width.'", "'.$flash_height.'", "10.0.0", "'.JURI::root().'components/com_jmonoslideshow/assets/flash/expressInstall.swf", flashvars, params, attributes);
		</script>';

	}

	/**
	 * Return html
	 * @param array params
	 * @return string
	 */

	function getHTML ($params)
	{

		if ($params->get('show_errorFlash', 1) == 1) $error = "<div> ".JText::_( 'COM_JMONOSLIDESHOW_PROBLEM_FLASH' )."</div>"; else $error ="";
		return  '<div align="'.$params->get('align_slideshow', "center").'">
		<div id="'.$params->get('div_id', "jmonoslideshow").'">
		'.$error.'
		</div>
        </div>';

	}

	

	/**

	 * Return slidedeshow

	 * @param array params

	 * @param sting type. value : 'slideshow' (display slideshow with no album) or 'album' (display slideshow with album)

	 * @param array row

	 * @param array album

	 * @return string

	 */

	function getSlideshow ($params, $type, $row, $albums)

	{

		$slideshow = SlideshowHelper::getSwfobject($params, $type, $row, $albums);

		$slideshow .= SlideshowHelper::getHTML($params);

		return $slideshow;

	}

	

	/**
     * Returns a filter string for quote
     */

	function getModelParameters ($id)

	{

		//load model
		require_once( JPATH_BASE.DS.'components'.DS.'com_jmonoslideshow'.DS.'models'.DS.'model.php' );
		$model = new JmonoslideshowModelModel();
		return $model->getParams($id);

	}
	
	/**
     * Returns a filter string for quote
     */

	function filterQuote ($string)

	{

		$string = htmlspecialchars($string, ENT_QUOTES);
		return $string = str_replace(CHR(13).CHR(10),"",$string);

	}

	

}